package com.twu.biblioteca;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * Created by xndong on 10/6/14.
 */
public class UserList {
    static ArrayList<Customer> userList = new ArrayList<Customer>();
    public UserList(){
        this.userList.add(new Customer("Ada","ada@a.com",1234567890, "www-wwww"));
        userList.add(new Customer("Biz","biz@a.com",1234567890, "qqq-qqqq"));
        userList.add(new Customer("Code","code@a.com",1234567890, "aaa-aaaa"));
        userList.add(new Customer("Demon","demon@a.com",1234567890, "zzz-zzzz"));
        userList.add(new Customer("Ema","ema@a.com",1234567890, "sss-ssss"));
    }

    public UserList(Customer item){
        userList.add(item);
    }

    public UserList(ArrayList<Customer> items){
        userList = items;
    }

    public static Customer Get(String input){
        if(input.isEmpty()) return null;
        Iterator<Customer> it = userList.iterator();
        while (it.hasNext()) {
            if( it.next().Identity.equals(input)) return it.next();
        }
        return null;
    }

}
